#!/usr/bin/env node

let userName = process.argv[2];
let password = process.argv[3];

// 检查参数数量
// if (userName === undefined || password === undefined) {
//     console.error('Usage: cmd user_name password');
//     process.exit(1);
//   }

// console.log('user name:', userName);
// console.log('password:', password);

// const msg = `${userName}:${password}`;
// console.log('msg:',msg);

// const buf = Buffer.from(msg);
// console.log('base64:', buf.toString('base64'));

// 第二种
// 使用 crypto 模块进行 Base64 编码
const crypto = require('crypto');
const encoded = crypto.createHash('sha256').update(msg).digest('base64');
console.log('Base64 编码 (crypto):', encoded);

